                                                                                                                                                                                           ?? buffers
1 #include "Processbar.h"
2 #include <string.h>
3 #include <unistd.h>
4
5 #define Length 101
6 #define Style '='
7
8 const char* lable = "|/-\\";
9
10 void ProcBar(double total, double current)
11 {
	12   char bar[Length];
	13   memset(bar, '\0', sizeof(bar));
	14   int len = strlen(lable);
	15
		16   int cnt = 0;
	17   double rate = (current * 100.0) / total;
	18   int loop_count = (int)rate;
	19   while (cnt <= loop_count)
		20   {
		21     bar[cnt++] = Style;
		22
			23   }
	24   printf("[%-100s][%.1lf%%][%c]\r", bar, rate, lable[cnt % len]);
	25   fflush(stdout);
	26
		27 }
~
